package cn.lanqiao.mapper;

import java.util.List;
import java.util.Map;

import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Options;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.springframework.stereotype.Repository;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;import cn.lanqiao.entity.Student;

/**
 * 学生管理模块
 * @author yejun
 */

@Repository
public interface StudentMapper {

	//展示所有数据
	@Select("select * from student")
	public List<Student> listAllStudent();
	//分页
	public List<Student> studentPages( Map<String,Object> map );
	//获取总记录数
	public int count( String  searchkey );
	//详情查看
	public Student getStudent(Integer studentId);
	//删除
	public int delete(Integer studentId);
	//修改
	public int update(Student student);
	//添加
	public int insert(Student student);
	//获取用户数
	public int total();
	
	public Integer test();

	List<Student> selectStudent();

	void updateStudentByName(Student student);

	void addStudent(Student student);

	int selectByName(String StudentName);
	
	//学生信息添加
	@Options(useGeneratedKeys = true,keyProperty = "studentId")
    @Insert("insert into student(studentName,grade,major,studentClass,institute,tel,email,pwd,cardId,sex,role) values " +
            "(#{studentName},#{grade},#{major},#{studentClass},#{institute},#{tel},#{email},#{pwd},#{cardId},#{sex},#{role})")
	public int add(Student student);
	/**
     * 分页查询所有学生
     * @param page
     * @return List<Student>
     */
    @Select("select * from student")
    public IPage<Student> PageStudent(Page page);
  //根据id查询学生信息
    @Select("select * from student where studentId = #{studentId}")
    public Student findById(Integer studentId);
   //根据id删除学生信息
    @Delete("delete from student where studentId = #{studentId}")
    public int deleteById(Integer studentId);
    /**
     *更新所有学生信息
     * @param student 传递一个对象
     * @return 受影响的记录条数
     */
    /**
     * 更新密码
     * @param student
     * @return 受影响的记录条数
     */
    @Update("update student set pwd = #{pwd} where studentId = #{studentId}")
    public int updatePwd(Student student);
}
